// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require(CONFIG.BasePath + "js/enterprise/base");
	var router = require("../hash/pageRouter");
	var constant = require("constant");
	var css_pickup = require("./accountDetainedApplicationDetail.css");
	var databind = require("databind");
	var detainedId;
	var inventoryId = [];

	var init = function(page) {
		detainedId = page.params.detainedId;
		inquireDetainedApplicationDetail();
		router.init();
		initEvent();
	};

	var initEvent = function() {
		if (base.getData("sid") == null) {
			location.href = "../login/login.html";
		}
		//点击项目基本详情financeDetail
		$(".financeDetail").unbind("click").click(function(){
			router.route("account/accountDetail.html?financeId="+financeId,true);
                	
		});
	};

	//查询扣货申请详情
	var inquireDetainedApplicationDetail = function() {
		base.fnAjax({
			action: "inquireDetainedApplicationDetail.json",
			async: false,
			oData: {
				detainedId: detainedId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($("#accountDetainedApplicationDetail"), data.datas[0]);
					juicer.register("getValueByKey", constant.getValueByKey);
					var tpl = $("#detainedDetailTpl").html();
					var html = juicer(tpl, data);
					$("#detaniedBody").html(html);
					
					$(".detainedDetail").unbind("click").click(function(){
						router.route("account/accountTallyDetail.html?inventoryId="+$(this).parents("tr").attr("inventoryId"));
					});
				} else {
				}
			}
		});
	};

	return {
		init: init
	};
});